﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
    var reportUrl = Newtouch.Core.Common.Utils.ConfigurationHelper.GetAppConfigValue("ReportUrl");
}
<script src="@SiteUrl.GetStaticResourceScriptUrl("~/js/wdtree/tree.js")"></script>
<link href="@SiteUrl.GetStaticResourceScriptUrl("~/js/wdtree/tree.css")" rel="stylesheet" />
<style type="text/css">
    .ui-th-ltr, .ui-jqgrid .ui-jqgrid-htable th.ui-th-ltr {
        border: solid 1px #ddd;
    }

        .ui-th-ltr div, .ui-jqgrid .ui-jqgrid-htable th.ui-th-ltr div {
            text-align: center;
        }

    .ui-jqgrid .ui-jqgrid-btable tbody tr.jqgrow td {
        border: solid 1px #ddd;
    }

    .ui-jqgrid .table-bordered th {
        padding-top: 4px;
        padding-bottom: 4px;
    }

    .dv-left {
        width: 200px;
        float: left;
    }

    .dv-left-tree {
        overflow-y: auto;
        border-radius: 4px;
        background: white;
    }

    .dv-left-title {
        padding: 6px 10px;
        border-bottom: 1px solid transparent;
        border-top-left-radius: 3px;
        border-top-right-radius: 3px;
        border-color: #ddd;
        background-color: white;
    }

    .dv-right {
        float: left;
        margin-left: 5px;
    }

    .dv-right-order {
        width: 100%;
    }
</style>
<div class="dv-body">
    <div class="dv-left">
        <div class="panel panel-default">
            <div class="panel-heading navb-bg">
                筛选条件
            </div>
            <table class="form" style="width:95%">
                <tbody>
                    <tr>
                        <th class="formTitle">姓名/住院号：</th>
                        <td class="formValue">
                            <input id="keyword" type="text" onblur="getPatTreeList()" class="form-control">
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">在院状态：</th>
                        <td class="formValue formDdlSelectorTd">
                            <select class="form-control" id="zyzt">
                                <option value="">全部</option>
                                <option value="zy" selected>在院</option>
                                <option value="cy">出院</option>
                            </select>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="dv-left-title">
            患者列表
        </div>
        <div class="dv-left-tree" id="PatTreeList"></div>
    </div>
    <div class="dv-right">
        <form name="form1">
            <div class="panel panel-default" style="margin-bottom:5px;">

                <div style="padding: 2px 0;">
                    <table class="form">
                        <tr>
                            <th class="formTitle">姓名：</th>
                            <td class="formValue">
                                <label id="xm"></label>
                            </td>
                            <th class="formTitle">性别：</th>
                            <td class="formValue">
                                <label id="xb"></label>
                            </td>
                            <th class="formTitle">病区：</th>
                            <td class="formValue">
                                <label id="bq"></label>
                            </td>
                            <th class="formTitle">年龄：</th>
                            <td class="formValue">
                                <label id="nl"></label>
                            </td>
                        </tr>
                         <tr>
                            <td class="formValue formDdlSelectorTd">
                                <select id="hljllx" onchange="querytype()" class="form-control" style="width:100px;">
                                    <option value="0">一般护理记录</option>
                                    <option value="1">病危(重)护理记录</option>
                                    <option value="2">手术护理记录</option>
                                </select>
                            </td>
                            <th class="formTitle">日期：</th>
                            <td class="formValue" colspan="4">
                                <input id="kssj" type="text" class="form-control input-wdatepicker" style="width:42%; float:left;" value="@DateTime.Now.ToString("yyyy-MM-01")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
                                <span style="margin-left:1%;float:left">—</span>
                                <input id="jssj" type="text" class="form-control input-wdatepicker" style="width:43%; float:left;margin-left:1%;" value="@DateTime.Now.ToString("yyyy-MM-dd")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
                            </td>
                            <td class="formValue" hidden="hidden">
                                <input id="zyh" type="text" class="form-control" />
                            </td>
                            <th class="formTitle"></th>
                            <td class="formTitle"><input type="button" id="btn_search" style="width:100%;" class="btn btn-primary" value=" 查 询 " /></td>

                            <td class="formValue" hidden="hidden">
                                <input type="button" id="btn_zyh" class="btn btn-default" value="住院号" />
                            </td>
                            @*<td class="formTitle"><span class="required">*</span>病区：</td>
        <td class="formValue">
            <select id="WardCode" class="form-control">
                <option>
                    全部
                </option>
            </select>
        </td>*@
                            <td class="formTitle" hidden="hidden"><input onclick="showDelete()" value="0" name="isShowDelete" checked="checked" type="checkbox" />显示已作废</td>
                            <td class="formValue"></td>
                        </tr>
                        <tr>
                            <td class="formValue" colspan="4">
                                &nbsp;
                                <input type="button" id="btn_add" class="btn btn-primary" value=" 新 录 入 " />
                                &nbsp;
                                <input type="button" id="btn_edit" class="btn btn-primary" value=" 修 改 " />
                                &nbsp;
                                <input type="button" id="btn_delete" class="btn btn-primary" value=" 作 废 " />
                                &nbsp;
                                <input type="button" id="btn_export" class="btn btn-primary" value=" 打 印 " />
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </form>
        <div id="gridPanel" class="gridPanel">
            <table id="gridList"></table>
        </div>
        @*<div id="gridPanelwz" style="display:none">
            <div class="gridPanel">
                <table id="gridListwz"></table>
            </div>
        </div>
        <div id="gridPanelss" class="gridPanel" style="display:none">
            <table id="gridListss"></table>
        </div>*@
    </div>
</div>
<script>
        $(function () {
            $(window).resize(function () {//浏览器窗口调整大小时重新计算宽高
                $(".dv-body").height($(window).height());
                $(".dv-body").width($(window).width());
            });
            var rightWidth = $(".Newtouch_iframe", parent.document).width() - $(".dv-left").width() - 30;
            $(".dv-right").width(rightWidth);
            var currentobj = JSON.parse(sessionStorage.getItem('currentpatobj'));//护士患者一览
            if (currentobj) {
                $('#zyh').val(currentobj.zyh);
                sessionStorage.removeItem("currentpatobj");
            }
            initControl();
            gridList();
            $("#gridList").jqGrid('setFrozenColumns');//设置冻结列
            getPatTreeList();
            $('#zyzt').change(function () {
                getPatTreeList();
            });
    });
    function showDelete() {
        btn_search();
    }
    function initControl() {
        $('#btn_zyh').click(function () {
            $.modalOpen({
                id: "patSearch",
                title: "住院患者查询",
                url: "/PatientList/InPatSearchView?allowunselected=true&zybz=1,2,3,7&t=" + Math.random() + "&zyh=" + '',
                width: "700px",
                height: "600px",
                callBack: function (iframeId) {
                    top.frames[iframeId].AcceptClick(function (patData) {
                        if (patData && patData.zyh) {
                            $('#zyh').val(patData.zyh);
                        }
                        else {
                            $('#zyh').val('');
                        }
                    });
                }
            });
        });

        $('#zyh').keyupEnterEvent(function () {
            btn_search();
		});

		//$("#WardCode").bindSelect({
		//	url: "/SystemManage/BaseData/GetAuthedWardSelectJson",
		//});
        $('#btn_search').click(function () {
            btn_search();
        });
    }
    function getPatTreeList() {
        $("#PatTreeList").treeview({
            height: $(window).height() - 150,
            slimscroll: false,
            showcheck: false,
            url: "/MedicalRecordManage/NursingRecord/GetPatWardTree?zyzt=" + $('#zyzt').val() + "&keyword=" + $('#keyword').val(),
            onnodeclick: function (item) {
                if (item.value && item.Ex1 == "c") {
                    getlistbyzyh(item.value, item.Ex2, item.Ex3);
                    $.ajax({
                        url: "/MedicalRecordManage/NursingRecord/GetPatWard",
                        data: { zyh: item.value },
                        dataType: "json",
                        async: false,
                        success: function (data) {
                            $("#xm").text(data.hzxm);
                            if (data.sex == "1") {
                                $("#xb").text("男");
                            }
                            else { $("#xb").text("女"); }
                            $("#bq").text(data.bqmc);
                            $("#nl").text(data.nl+"岁");
                        }
                    });
                }
            }
        });
    }
    function getlistbyzyh(zyh,rqrq,cqrq) {
        $("#zyh").val(zyh);
        $("#kssj").val(rqrq);
        $("#jssj").val(cqrq);
        btn_search();
    }
    function querytype() {
        btn_search();
        //if ($("#hljllx").val() == "1") {
        //    $("#gridPaneltss").css("display", "none");
        //    $("#gridPanel").css("display", "none");
        //    $("#gridPanelwz").css("display", "block");
        //    gridListwz();
        //}
        //else if ($("#hljllx").val() == "2") {
        //    $("#gridPanel").css("display", "none");
        //    $("#gridPanelwz").css("display", "none");
        //    $("#gridPanelss").css("display", "block");
        //    gridListss();
        //} else {
        //    $("#gridPanelwz").css("display", "none");
        //    $("#gridPanelss").css("display", "none");
        //    $("#gridPanel").css("display", "block");
        //    gridList();
        //}
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            postData: {},
            url: "/MedicalRecordManage/NursingRecord/GetGridJson",
            postData: getSearchPostData(),
            height: $(window).height() - 150,
            colModel: [
                { label: "Id", name: "Id", hidden: true, frozen: true },
                {
                    label: "住院号", name: "zyh", width: 80, align: 'left',
                    formatter: function (cellvalue, options, rowobject) {
                        if (rowobject.zt == "0") {
                            cellvalue += '<span style="color:red;">【作废】</span>';
                        }
                        return cellvalue;
                    }, frozen: true
                },
                {
                    label: "姓名", name: "xm", width: 80, align: 'left', frozen: true
                },
                {
                    label: "日期", name: "rq", width: 110, align: 'left',
                    formatter: function (cellvalue, options, rowobject) {
                        //日期 时间点 相关状态
                        var val = $.getDate({ date: cellvalue });
                        val += " " + rowobject.sj;
                        if (rowobject.brzt) {
                            val += " " + $.enum.getDescByValue("EnumHlbrzt", rowobject.brzt);
                        }
                        return val;
                    }, frozen: true
                },
                { label: "体温(℃)", name: "tw", width: 70, align: 'left' },
                { label: "脉率(次/min)", name: "ml", width: 70, align: 'left' },
                { label: "呼吸频率(次/min)", name: "hxpl", width: 70, align: 'left' },
                { label: "收缩压(mmHg)", name: "ssy", width: 70, align: 'left' },
                { label: "舒张压(mmHg)", name: "szy", width: 70, align: 'left' }, 
                { label: "意识", name: "ys", width: 70, align: 'left' }, 
                { label: "左瞳孔", name: "tk_z", width: 70, align: 'left' }, 
                { label: "右瞳孔", name: "tk_y", width: 70, align: 'left' },
                { label: "光反应-左", name: "dgfs_z", width: 70, align: 'left' }, 
                { label: "光反应-右", name: "dgfs_y", width: 70, align: 'left' }, 
                { label: "血氧饱和度(%)", name: "xybhd", width: 70, align: 'left' },
                { label: "吸氧(L/min)", name: "xybhd", width: 70, align: 'left' },
                { label: "皮肤护理", name: "pfhl", width: 70, align: 'left' },
                { label: "导管护理描述", name: "dghl", width: 70, align: 'left' },
                { label: "病情观察及措施", name: "hlgcjg", width: 70, align: 'left' },
                { label: "时间点", name: "sj", width: 50, align: 'left', hidden: true },
                { label: "护理等级", name: "hldj", width: 70, align: 'left' },
                { label: "护理类型", name: "hllx", width: 70, align: 'left' },
                { label: "过敏史", name: "gms", width: 70, align: 'left' },
                { label: "体重(kg)", name: "tz", width: 70, align: 'left' },
                { label: "脉率(次/min)", name: "ml", width: 70, align: 'left' },
                { label: "足背动脉搏动标志", name: "zbdmbz", width: 70, align: 'left' },
                { label: "饮食情况代码", name: "ysqk", width: 70, align: 'left' },
                { label: "气管护理代码", name: "qghl", width: 70, align: 'left' },
                { label: "体位护理", name: "twhl", width: 70, align: 'left' },
                { label: "营养护理", name: "yyhl", width: 70, align: 'left' },
                { label: "饮食指导代码", name: "yszd", width: 70, align: 'left' },
                { label: "心理护理代码", name: "xlhl", width: 70, align: 'left' },
                { label: "安全护理代码", name: "aqhl", width: 70, align: 'left' },
                { label: "简要病情", name: "jybq", width: 70, align: 'left' },
                { label: "护理观察项目名称", name: "hlgcxm", width: 70, align: 'left' },
                { label: "护理操作名称", name: "hlczmc", width: 70, align: 'left' },
                { label: "护理操作项目类目名称", name: "hlczxmmc", width: 70, align: 'left' },
                { label: "护理操作结果", name: "hlczjg", width: 70, align: 'left' },
                { label: "发出手术安全核对表标志", name: "fcssaqb", width: 70, align: 'left' },
                { label: "收回手术安全核对表标志", name: "shssaqb", width: 70, align: 'left' },
                { label: "发出手术风险评估表标志", name: "fcssfxpgb", width: 70, align: 'left' },
                { label: "收回手术风险评估表标志", name: "shssfxpgb", width: 70, align: 'left' },
                { label: "隔离标志", name: "glbz", width: 70, align: 'left' },
                { label: "隔离种类代码", name: "glzl", width: 70, align: 'left' },
                { label: "护士签名", name: "hsqm", width: 70, align: 'left' },
                { label: "录入用户", name: "CreatorCode", width: 60, align: 'left' },
                { label: '录入时间', name: 'CreateTime', width: 120, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' } },
            ],
            rowNum: 10,
            //pager: "#gridPager",
            //sortname: 'rq , sj',
            viewrecords: true,
            rownumbers: false,
            ondblClickRow: function (rowid) {
                gridEditRow(rowid);
            },
            gridComplete: function () {

            }
        });
        //二级菜单
        $gridList.jqGrid('setGroupHeaders', {
            useColSpanStyle: true,
            groupHeaders: [
                {
                    startColumnName: 'syl',
                    numberOfColumns: 4,
                    titleText: '摄入量'
                },
                {
                    startColumnName: 'otl',
                    numberOfColumns: 10,
                    titleText: '摄出量'
                }
            ]
        });

        btn_search();
    }
    function btn_search() {
        $("#gridList").jqGrid('setGridParam', {
            postData: getSearchPostData(),
            page: 1,
        }).trigger('reloadGrid');
    }
    //查询条件
    function getSearchPostData() {
        var kssj = $("#kssj").val();
        var jssj = $("#jssj").val();
        var zyh = $("#zyh").val();
        if (zyh!=null&&zyh!="") {
            zyh = zyh;
        }
		var wardCode ="";
		var isShowDelete = $("input[name='isShowDelete']")[0].checked;
        return { zyh: zyh, kssj: kssj, jssj: jssj, wardCode: wardCode, isShowDelete: isShowDelete, hllx: $("#hljllx").val()};
    };

    $("#btn_add").click(function () {
        InpatientVitalSignsForm();
    });

    $("#btn_edit").click(function () {
        var seleId = $('#gridList').jqGrid('getGridParam', 'selrow');
        if (seleId) {
            //请求修改该行
            gridEditRow(seleId);
        }
        else {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
    });

    $("#btn_delete").click(function () {
        var seleId = $('#gridList').jqGrid('getGridParam', 'selrow');
        if (seleId) {
            //请求作废该行
            gridDeleteRow(seleId);
        }
        else {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
    });
    $("#btn_export").click(function () {
        var reportServerHOST = '@(ViewBag.ReportServerHOST)';
        var orgId = '@(ViewBag.OrgId)';
        var kssj = $("#kssj").val();
        var jssj = $("#jssj").val();
        var zyh = $('#zyh').val();
        if (!zyh) {
            $.modalAlert("缺少住院号", "warning");
            return;
        }
        var yzlx = "hljld" +"|" +$("#hljllx").val();
        window.open("/SystemManage/YzPreView/YzPreView?zyh=" + zyh + "&orgId=" + orgId + "&yzlx=" + yzlx);
       

    });
    function gridEditRow(rowid) {
        var rowData = $("#gridList").jqGrid('getRowData', rowid);
        InpatientVitalSignsForm(rowData.Id);
    }

    function gridDeleteRow(rowid) {
        var rowData = $("#gridList").jqGrid('getRowData', rowid);
        $.deleteForm({
            prompt: "注：您确定要作废【" + "住院号：" + rowData.zyh + "<br/>时间：" + rowData.rq+ "】该条数据吗？",
            url: "/MedicalRecordManage/NursingRecord/DeleteForm",
            param: { keyValue: rowData.Id },
            success: function () {
                $("#gridList").trigger("reloadGrid");
            }
        })
    }

    function InpatientVitalSignsForm(smtzId) {
        if ($("#zyh").val()=="") {
            $.modalAlert("请选择病人！", "warning");
            return;
        }
        if ($("#hljllx").val() == "1") {
            $.modalOpen({
                id: "InpatientVitalSignsForm",
                title: "危重护理记录录入",
                url: "/MedicalRecordManage/NursingRecord/WZForm?smtzId=" + smtzId + "&zyh=" + $("#zyh").val() + "&xm=" + $("#xm").text(),
                width: "900px",
                height: "750px",
                showleftlalbel: !!!smtzId,  //新增时显示 '确认并关闭按钮'
                leftlalbelchecked: true,
                leftlabeltext: "连续录入",
                leftlalbelcheckedasClose: false,
                callBack: function (iframeId, isClose) {
                    var ret = top.frames[iframeId].AcceptClick(function () {
                        $("#gridList").trigger("reloadGrid");
                        if (isClose === undefined || isClose === true) {
                            top.frames[iframeId].$.modalClose();
                        }
                    });
                }
            });
        } else if ($("#hljllx").val() == "2") {
            $.modalOpen({
                id: "InpatientVitalSignsForm",
                title: "手术护理记录录入",
                url: "/MedicalRecordManage/NursingRecord/SSForm?smtzId=" + smtzId + "&zyh=" + $("#zyh").val() + "&xm=" + $("#xm").text(),
                width: "900px",
                height: "750px",
                showleftlalbel: !!!smtzId,  //新增时显示 '确认并关闭按钮'
                leftlalbelchecked: true,
                leftlabeltext: "连续录入",
                leftlalbelcheckedasClose: false,
                callBack: function (iframeId, isClose) {
                    var ret = top.frames[iframeId].AcceptClick(function () {
                        $("#gridList").trigger("reloadGrid");
                        if (isClose === undefined || isClose === true) {
                            top.frames[iframeId].$.modalClose();
                        }
                    });
                }
            });
        } else {
            $.modalOpen({
                id: "InpatientVitalSignsForm",
                title: "一般护理记录录入",
                url: "/MedicalRecordManage/NursingRecord/Form?smtzId=" + smtzId + "&zyh=" + $("#zyh").val() + "&xm=" + $("#xm").text(),
                width: "800px",
                height: "700px",
                showleftlalbel: !!!smtzId,  //新增时显示 '确认并关闭按钮'
                leftlalbelchecked: true,
                leftlabeltext: "连续录入",
                leftlalbelcheckedasClose: false,
                callBack: function (iframeId, isClose) {
                    var ret = top.frames[iframeId].AcceptClick(function () {
                        $("#gridList").trigger("reloadGrid");
                        if (isClose === undefined || isClose === true) {
                            top.frames[iframeId].$.modalClose();
                        }
                    });
                }
            });
        }
        
	}


</script>
